﻿package mortal.game.view.forging.renderer
{
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class BatRefreshCellRenderer extends GCellRenderer
    {
        private var _batRefreshBg:GBitmap;
        private var _replaceBtn:GButton;
        private var _propList:GTileList;
        private var _combat:BitmapNumberText;
        private var _upArrow:GBitmap;
        private var _downArrow:GBitmap;

        public function BatRefreshCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._batRefreshBg = UIFactory.gBitmap(ImagesConst.BatRefreshBg, 0, 0, this);
            this.pushUIToDisposeVec(UIFactory.bg(0, 1, 134, 23, this, ImagesConst.RegionTitleBg));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.Text_NewCombat, 22, 4, this));
            this._upArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 63, 4, this);
            this._upArrow.visible = false;
            this._downArrow = UIFactory.gBitmap(ImagesConst.downArrow, 63, 4, this);
            this._downArrow.visible = false;
            this._combat = UIFactory.bitmapNumberText(76, 5, "FightInfoNum.png", 12, 15, -1, this);
            this._replaceBtn = UIFactory.gButton(Language.getString(41051), 38, 145, 46, 20, this, "ButtonNew");
            this._propList = UIFactory.tileList(4, 27, 124, 115, this);
            this._propList.columnWidth = 124;
            this._propList.rowHeight = 19;
            this._propList.horizontalGap = 0;
            this._propList.verticalGap = 0;
            this._propList.setStyle("skin", new Bitmap());
            this._propList.setStyle("cellRenderer", RefreshPropCellRenderer);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super._data = param1;
            var _loc_2:* = param1.propData as DataProvider;
            this._propList.dataProvider = _loc_2;
            this._propList.drawNow();
            if (_loc_2.length != 0)
            {
                this._replaceBtn.visible = true;
            }
            else
            {
                this._replaceBtn.visible = false;
            }
            var _loc_3:int = 0;
            while (_loc_3 < this._propList.length)
            {
                
                (this._propList.itemToCellRenderer(this._propList.getItemAt(_loc_3)) as RefreshPropCellRenderer).hideLock();
                (this._propList.itemToCellRenderer(this._propList.getItemAt(_loc_3)) as RefreshPropCellRenderer).changePosition();
                _loc_3++;
            }
            if (param1.hasOwnProperty("hasExpectAttr") && param1.hasExpectAttr == true)
            {
                this.addSelEffect();
            }
            else
            {
                this.removeSelEffect();
            }
            this._upArrow.visible = false;
            this._downArrow.visible = false;
            this._combat.text = "";
            return;
        }// end function

        public function updateCombat(param1:int) : void
        {
            this._combat.text = "" + Math.abs(param1);
            if (param1 > 0)
            {
                this._upArrow.visible = true;
                this._downArrow.visible = false;
            }
            else if (param1 < 0)
            {
                this._upArrow.visible = false;
                this._downArrow.visible = true;
            }
            if (param1 == 0)
            {
                this._upArrow.visible = true;
                this._downArrow.visible = false;
            }
            return;
        }// end function

        public function addSelEffect() : void
        {
            var _loc_1:Array = [FilterConst.colorGlowFilter(11252925)];
            EffectManager.glowFilterUnReg(this._batRefreshBg);
            EffectManager.glowFilterReg(this._batRefreshBg, _loc_1, 1, 10, 0, 0);
            return;
        }// end function

        public function removeSelEffect() : void
        {
            EffectManager.glowFilterUnReg(this._batRefreshBg);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._replaceBtn.dispose(param1);
            this._propList.dispose(param1);
            this._combat.dispose(param1);
            this._batRefreshBg.dispose(param1);
            this._upArrow.dispose(param1);
            this._downArrow.dispose(param1);
            this._replaceBtn = null;
            this._propList = null;
            this._combat = null;
            this._batRefreshBg = null;
            this._upArrow = null;
            this._downArrow = null;
            return;
        }// end function

    }
}
